<%@ page import="io.github.ilkgunel.pojo.Student" %>
<%@ page import="io.github.ilkgunel.dao.test2_3" %>
<%@ page import="java.util.List" %>
<%@ page import="io.github.ilkgunel.pojo.Course" %>
<%@ page import="io.github.ilkgunel.dao.coursefind" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
	<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>基于Bootstrap可编辑的HTML表格jquery插件</title>
	<link rel="stylesheet" href="https://www.jq22.com/jquery/bootstrap-3.3.4.css">
	<link rel="stylesheet" href="https://www.jq22.com/jquery/font-awesome.4.7.0.css">
	<style type="text/css">
.box {
	width: 20px;
	height: 20px;
	padding: 2px;
	border: 1px solid #ccc;
	border-radius: 2px;
}
</style>
	</head>
	<body>
    <%
        List<Course> list = null;
        coursefind dao=new coursefind();
        list=dao.find();
        if(list==null){
    %>
    <script>
        alert("kongla")
    </script>
    <%
        }
    %>
<h1 style="text-align: center">批量编辑</h1>
    <div class="col-md-12"  style="padding-bottom:2em;">
        <button class="btn btn-info" onclick="tijiao()"> 保存</button>
    </div>
    <div class="col-md-12"  style="padding-bottom:2em;">
        <button class="btn btn-info" onclick="location.href='test4_1.jsp'"> 返回</button>
    </div>
<div class="container">
      <div class="row">
    <div class="col-md-12" style="padding:2em 0;">
          <div class="table-responsive">
        <table class="table table-bordered table-striped" id="mytable">
            <thead>
            <tr>
                <th >id</th>
                <th>课序号</th>
                <th>课程名</th>
                <th>先导课</th>
                <th>学分</th>

            </tr>
            </thead>
            <tbody>
                <%

                            Course course=null;
                            if(list!=null&&list.size()!=0){

                                for(int i=0;i<list.size();i++) {
                                    course = list.get(i);


                        %>
            <tr class="gradeX">
                <td ><%=course.get_id()%>
                <td><%=course.getCid()%>
                <td><%=course.getName()%>

                <td><%=course.getFcid()%></td>
                <td ><%=course.getCredit()%></td>
            </tr>
                <%}}
                        %>
            </tbody>
            </table>
      </div>
        </div>

  </div>
    </div>
<script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script>
<script type="text/javascript" src="js/bootstable.js"></script>
<script type="text/javascript">

		$('#mytable').SetEditable({
			$addButton: $('#add')
		});
        /**
         * 遍历表格内容返回数组
         * @param  Int   id 表格id
         * @return Array
         */
      /*  function getTableContent(id){
            content=""
            var mytable = document.getElementById(id);
            var data = [];
            for(var i=0,rows=mytable.rows.length; i<rows; i++){
                for(var j=0,cells=mytable.rows[i].cells.length; j<cells; j++){
                    if(!data[i]){
                        data[i] = new Array();
                    }
                    data[i][j] = mytable.rows[i].cells[j].innerHTML;
                    content+=data[i][j]+" "

                }
                content+="哈哈\n"
            }
            return data;
        }*/
        function getTableContent(id){
            content=""
            var mytable = document.getElementById(id);
            var data = [];
            for(var i=0,rows=mytable.rows.length; i<rows; i++){
                for(var j=0; j<5; j++){
                    if(!data[i]){
                        data[i] = new Array();
                    }
                    data[i][j] = mytable.rows[i].cells[j].innerText;
                    content+=data[i][j]+" "

                }
                content+="哈哈\n"
            }
            return data;
        }
       function tijiao ()
       {
           var data=  getTableContent("mytable")
           window.location.href="/web/test4_3?data="+JSON.stringify(data)

       }
	</script>
</body>
</html>
